package com.example.pptls;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
import android.widget.TextView;

public class Score extends Activity {
	
	TextView score;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_score);
		
		score = (TextView)findViewById(R.id.textScore);
		leerFichero();
	}

	
	
	
	public void leerFichero(){
		String texto="";
		try
		{
		    BufferedReader fin =
		        new BufferedReader(new InputStreamReader(openFileInput("fichero.txt")));
		    int i=0;
		    try{
		    texto=fin.readLine();
		    }
		    catch(Exception e){
		    	score.setText("No hay partidas anteriores.");
		    }
		  while (i<5 && texto!=null){
			  score.setText(texto);
			  texto=fin.readLine();
		  }
		    
		    fin.close();
		}
		catch(Exception ex)
		{
		    Log.e("Ficheros", "Error al leer fichero desde memoria interna");
		}
		
	}
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.ficheros, menu);
		return true;
	}

}
